package com.jtny.nytb.equipment.service.impl;

import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.jtny.component.contants.GenericConstants;
import com.jtny.component.core.util.PageUtils;
import com.jtny.component.core.util.QueryWrapperUtils;
import com.jtny.component.dto.CurrentUserDTO;
import com.jtny.component.entity.LocalHolder;
import com.jtny.component.entity.PageData;
import com.jtny.component.enums.GenericStatusEnum;
import com.jtny.component.exception.ServiceException;
import com.jtny.component.util.Assert;
import com.jtny.component.util.BeanUtils;
import com.jtny.component.util.CurrentUserUtils;
import com.jtny.nytb.dataparam.service.serviceImpl.ConfigRuleManagementServiceImpl;
import com.jtny.nytb.equipment.domain.dataalgorithm.DataAlgorithmDO;
import com.jtny.nytb.equipment.domain.dataalgorithm.*;
import com.jtny.nytb.equipment.dto.dataalgorithm.*;
import com.jtny.nytb.equipment.enums.*;
import com.jtny.nytb.equipment.errorcode.*;
import com.jtny.nytb.equipment.service.DataAlgorithmBiz;
import com.jtny.nytb.equipment.vo.dataagorithm.*;
import com.jtny.nytb.dataparam.property.CodeRuleProperty;
import com.jtny.nytb.equipment.dao.dataalgorithm.DataAlgorithmDAO;
import com.jtny.nytb.equipment.dao.dataalgorithm.DataAlgorithmFormulaConfigDAO;
import com.jtny.nytb.equipment.dao.dataalgorithm.DataAlgorithmParamConfigDAO;
import com.jtny.nytb.equipment.dao.dataalgorithm.DataAlgorithmScriptConfigDAO;
import lombok.AllArgsConstructor;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.stream.Collectors;

/**
 * 数据算法基本信息管理BizImpl类
 * @package com.jtny.nytb.config.generic.dataalgorithm.biz.impl
 * @fileName DataAlgorithmBizImpl.java
 * @author 智慧能源中心-夏燕强
 * @createTime 2023年09月02日 14:05
 * @version 1.0
 * @Copyright© 2023 jtny
 * 江投能源技术研究院 版权所有
 */
@Service
@AllArgsConstructor
public class DataAlgorithmBizImpl extends ServiceImpl<DataAlgorithmDAO,DataAlgorithmDO> implements DataAlgorithmBiz {
    private ConfigRuleManagementServiceImpl configRuleManagementBizImpl;
    private CodeRuleProperty codeRuleProperty;
    private DataAlgorithmDAO dataAlgorithmDAO;
    private DataAlgorithmFormulaConfigDAO algorithmFormulaConfigDAO;
    private DataAlgorithmScriptConfigDAO algorithmScriptConfigDAO;
    private DataAlgorithmParamConfigDAO algorithmParamConfigDAO;

    @Override
    public PageData<DataAlgorithmBasicVO>  queryPage(DataAlgorithmPageQueryParamVO dataAlgorithmPageQueryParamVO) throws ServiceException {
        //入参校验
        if (dataAlgorithmPageQueryParamVO.getPageNo()==null){
            dataAlgorithmPageQueryParamVO.setPageNo(GenericConstants.DEFAULT_PAGE_NO);
        }
        if (dataAlgorithmPageQueryParamVO.getPageSize()==null){
            dataAlgorithmPageQueryParamVO.setPageSize(GenericConstants.DEFAULT_PAGE_SIZE);
        }
        //分页查询算法信息
        DataAlgorithmPageQueryParamDTO dataAlgorithmPageQueryParamDTO = BeanUtils.copyToObject(dataAlgorithmPageQueryParamVO, DataAlgorithmPageQueryParamDTO.class);
        PageData<DataAlgorithmDTO> dataAlgorithmDTOPageData = queryPage(dataAlgorithmPageQueryParamDTO);
        if (dataAlgorithmDTOPageData == null || CollUtil.isEmpty(dataAlgorithmDTOPageData.getData())) {
            return new PageData<>();
        }
        //遍历集合
        Collection<DataAlgorithmDTO> algorithmDTOCollection = dataAlgorithmDTOPageData.getData();
        List<DataAlgorithmBasicVO> algorithmBasicVOList = new ArrayList<>(algorithmDTOCollection.size());
        algorithmDTOCollection.forEach(algorithmDTO -> {
            DataAlgorithmBasicVO algorithmBasicVO = BeanUtils.copyToObject(algorithmDTO,DataAlgorithmBasicVO.class);
            algorithmBasicVOList.add(algorithmBasicVO);
        });

        PageData<DataAlgorithmBasicVO> pageDataForVO = dataAlgorithmDTOPageData.transformExcludeData(DataAlgorithmBasicVO.class);
        pageDataForVO.setData(algorithmBasicVOList);

        return pageDataForVO;
    }

    /**
     * 保存数据算法
     * @param algorithmScriptAndFormulaVO
     * @return
     * @throws ServiceException
     */
    @Override
    @Transactional(rollbackFor = Exception.class)
    public DataAlgorithmScriptAndFormulaVO saveDataAlgorithm(DataAlgorithmScriptAndFormulaVO algorithmScriptAndFormulaVO) throws ServiceException {
        CurrentUserDTO currentUserDTO = LocalHolder.getCurrentUser();

        //new前端返回对象
        DataAlgorithmScriptAndFormulaVO dataAlgorithmScriptAndFormulaVO = new DataAlgorithmScriptAndFormulaVO();

        //获取入参VO对象
        DataAlgorithmBasicVO dataAlgorithmBasicVO = algorithmScriptAndFormulaVO.getDataAlgorithmBasicVO();
        DataAlgorithmFormulaConfigVO dataAlgorithmFormulaConfigVO = algorithmScriptAndFormulaVO.getDataAlgorithmFormulaConfigVO();
        DataAlgorithmScriptConfigVO dataAlgorithmScriptConfigVO = algorithmScriptAndFormulaVO.getDataAlgorithmScriptConfigVO();

        //自定义一个单据编号规则标识,获取code
        String code = configRuleManagementBizImpl.queryCodeBycode(codeRuleProperty.getAlgorithmCodeRule(), null);
        dataAlgorithmBasicVO.setCode(code);

        //算法配置方案为计算公式配置
        if (dataAlgorithmBasicVO.getConfigurationScheme().equals("计算公式配置")){

            DataAlgorithmScriptAndFormulaDTO scriptAndFormulaDTO = new DataAlgorithmScriptAndFormulaDTO();
            //赋值
            DataAlgorithmDTO dataAlgorithm = BeanUtils.copyToObject(dataAlgorithmBasicVO, DataAlgorithmDTO.class);
            dataAlgorithm.setStatus(GenericStatusEnum.NORMAL.getValue());
            CurrentUserUtils.setCreateDefaultField(dataAlgorithm,currentUserDTO);
            List<DataAlgorithmParamConfigVO> configVOList = dataAlgorithmFormulaConfigVO.getParamConfigVOList();
            if (CollectionUtil.isEmpty(configVOList)){
                throw new ServiceException(DataAlgorithmErrorCodeEnum.PARAM_CONFIG_IS_NULL.getErrorCode(),DataAlgorithmErrorCodeEnum.PARAM_CONFIG_IS_NULL.getErrorMessage());
            }

            DataAlgorithmFormulaConfigDTO dataAlgorithmFormulaConfigDTO = BeanUtils.copyToObject(dataAlgorithmFormulaConfigVO, DataAlgorithmFormulaConfigDTO.class);
            scriptAndFormulaDTO.setDataAlgorithmDTO(dataAlgorithm);
            CurrentUserUtils.setCreateDefaultField(dataAlgorithmFormulaConfigDTO,currentUserDTO);

            List<DataAlgorithmParamConfigDTO> paramConfigDTO = BeanUtils.copyToList(configVOList, DataAlgorithmParamConfigDTO.class);
            List<DataAlgorithmParamConfigDTO> paramConfigDTOS = new ArrayList<>();
            //赋值
            paramConfigDTO.forEach(dataAlgorithmParamConfigDTO -> {
                CurrentUserUtils.setCreateDefaultField(dataAlgorithmParamConfigDTO,currentUserDTO);
                paramConfigDTOS.add(dataAlgorithmParamConfigDTO);
            });
            dataAlgorithmFormulaConfigDTO.setParamConfigDTOList(paramConfigDTOS);
            scriptAndFormulaDTO.setDataAlgorithmFormulaConfigDTO(dataAlgorithmFormulaConfigDTO);

            //保存
            DataAlgorithmScriptAndFormulaDTO dataAlgorithms = save(scriptAndFormulaDTO);
            dataAlgorithmScriptAndFormulaVO.setDataAlgorithmBasicVO(BeanUtils.copyToObject(dataAlgorithms.getDataAlgorithmDTO(),DataAlgorithmBasicVO.class));
            List<DataAlgorithmParamConfigDTO> paramConfigDTOList = dataAlgorithms.getDataAlgorithmFormulaConfigDTO().getParamConfigDTOList();
            List<DataAlgorithmParamConfigVO> dataAlgorithmParamConfigVOs = BeanUtils.copyToList(paramConfigDTOList, DataAlgorithmParamConfigVO.class);
            DataAlgorithmFormulaConfigVO  configVO = new DataAlgorithmFormulaConfigVO();
            configVO.setParamConfigVOList(dataAlgorithmParamConfigVOs);
            configVO.setFormula(dataAlgorithms.getDataAlgorithmFormulaConfigDTO().getFormula());
            dataAlgorithmScriptAndFormulaVO.setDataAlgorithmFormulaConfigVO(configVO);
        }

        //算法配置方案为算法脚本配置
        if (dataAlgorithmBasicVO.getConfigurationScheme().equals("算法脚本配置")){

            DataAlgorithmScriptAndFormulaDTO scriptAndFormulaDTO = new DataAlgorithmScriptAndFormulaDTO();
            //赋值
            DataAlgorithmDTO dataAlgorithm = BeanUtils.copyToObject(dataAlgorithmBasicVO, DataAlgorithmDTO.class);
            dataAlgorithm.setStatus(GenericStatusEnum.NORMAL.getValue());
            CurrentUserUtils.setCreateDefaultField(dataAlgorithm,currentUserDTO);


            List<DataAlgorithmParamConfigVO> configVOList = dataAlgorithmScriptConfigVO.getParamConfigVOList();
            if (CollectionUtil.isEmpty(configVOList)){
                throw new ServiceException(DataAlgorithmErrorCodeEnum.PARAM_CONFIG_IS_NULL.getErrorCode(),DataAlgorithmErrorCodeEnum.PARAM_CONFIG_IS_NULL.getErrorMessage());
            }
            DataAlgorithmScriptConfigDTO dataAlgorithmScriptConfigDTO = BeanUtils.copyToObject(dataAlgorithmScriptConfigVO, DataAlgorithmScriptConfigDTO.class);
            scriptAndFormulaDTO.setDataAlgorithmDTO(dataAlgorithm);

            CurrentUserUtils.setCreateDefaultField(dataAlgorithmScriptConfigDTO,currentUserDTO);

            List<DataAlgorithmParamConfigDTO> paramConfigDTO = BeanUtils.copyToList(configVOList, DataAlgorithmParamConfigDTO.class);
            List<DataAlgorithmParamConfigDTO> paramConfigDTOS = new ArrayList<>();
            //赋值
            paramConfigDTO.forEach(dataAlgorithmParamConfigDTO -> {
                CurrentUserUtils.setCreateDefaultField(dataAlgorithmParamConfigDTO,currentUserDTO);
                paramConfigDTOS.add(dataAlgorithmParamConfigDTO);
            });

            dataAlgorithmScriptConfigDTO.setParamConfigDTOList(paramConfigDTOS);
            scriptAndFormulaDTO.setDataAlgorithmScriptConfigDTO(dataAlgorithmScriptConfigDTO);
            //保存
            DataAlgorithmScriptAndFormulaDTO algorithm = save(scriptAndFormulaDTO);
            dataAlgorithmScriptAndFormulaVO.setDataAlgorithmBasicVO(BeanUtils.copyToObject(algorithm.getDataAlgorithmDTO(),DataAlgorithmBasicVO.class));
            List<DataAlgorithmParamConfigDTO> paramConfigDTOList = algorithm.getDataAlgorithmScriptConfigDTO().getParamConfigDTOList();
            List<DataAlgorithmParamConfigVO> dataAlgorithmParamConfigVOs = BeanUtils.copyToList(paramConfigDTOList, DataAlgorithmParamConfigVO.class);
            DataAlgorithmScriptConfigVO  configVO = new DataAlgorithmScriptConfigVO();
            configVO.setParamConfigVOList(dataAlgorithmParamConfigVOs);
            configVO.setAlgorithmId(algorithm.getDataAlgorithmScriptConfigDTO().getAlgorithmId());
            configVO.setRequestType(algorithm.getDataAlgorithmScriptConfigDTO().getRequestType());
            configVO.setScriptPath(algorithm.getDataAlgorithmScriptConfigDTO().getScriptPath());
            dataAlgorithmScriptAndFormulaVO.setDataAlgorithmScriptConfigVO(configVO);
        }
        //返给前端
        return dataAlgorithmScriptAndFormulaVO;
    }

    /**
     * 获取详情
     * @param algorithmId
     * @return
     * @throws ServiceException
     */
    @Override
    public DataAlgorithmScriptAndFormulaDTO detailDataAlgorithm(Long algorithmId) throws ServiceException {
        return getFormulaOrScriptById(algorithmId);
    }

    /**
     * 更新数据算法信息
     * @param dataAlgorithmScriptAndFormulaVO
     * @throws ServiceException
     */
    @Override
    @Transactional(rollbackFor = Exception.class)
    public void updateDataAlgorithm(DataAlgorithmScriptAndFormulaVO dataAlgorithmScriptAndFormulaVO) throws ServiceException {
        CurrentUserDTO currentUserDTO = LocalHolder.getCurrentUser();

        DataAlgorithmScriptAndFormulaDTO scriptAndFormulaDTO  = new DataAlgorithmScriptAndFormulaDTO();
        DataAlgorithmBasicVO dataAlgorithmBasicVO = dataAlgorithmScriptAndFormulaVO.getDataAlgorithmBasicVO();
        DataAlgorithmDTO dataAlgorithm = BeanUtils.copyToObject(dataAlgorithmBasicVO, DataAlgorithmDTO.class);
        scriptAndFormulaDTO.setDataAlgorithmDTO(dataAlgorithm);
        //判空
        if (dataAlgorithmBasicVO.getId()==null){
            throw new ServiceException(DataAlgorithmErrorCodeEnum.PARAM_NOT_FIND.getErrorCode(),DataAlgorithmErrorCodeEnum.PARAM_NOT_FIND.getErrorMessage());
        }
        //算法配置方案为计算公式配置
        if (dataAlgorithmBasicVO.getConfigurationScheme().equals("计算公式配置")){
            DataAlgorithmFormulaConfigVO dataAlgorithmFormulaConfigVO = dataAlgorithmScriptAndFormulaVO.getDataAlgorithmFormulaConfigVO();
            DataAlgorithmFormulaConfigDTO dataAlgorithmFormulaConfigDTO = BeanUtils.copyToObject(dataAlgorithmFormulaConfigVO, DataAlgorithmFormulaConfigDTO.class);
            List<DataAlgorithmParamConfigVO> paramConfigVOList = dataAlgorithmFormulaConfigVO.getParamConfigVOList();
            List<DataAlgorithmParamConfigDTO> paramConfigDTO = BeanUtils.copyToList(paramConfigVOList, DataAlgorithmParamConfigDTO.class);
            List<DataAlgorithmParamConfigDTO> paramConfigDTOS = new ArrayList<>();
            //赋值
            paramConfigDTO.forEach(dataAlgorithmParamConfigDTO -> {
                CurrentUserUtils.setUpdateDefaultField(dataAlgorithmParamConfigDTO,currentUserDTO);
                paramConfigDTOS.add(dataAlgorithmParamConfigDTO);
            });

            dataAlgorithmFormulaConfigDTO.setParamConfigDTOList(paramConfigDTOS);
            scriptAndFormulaDTO.setDataAlgorithmFormulaConfigDTO(dataAlgorithmFormulaConfigDTO);
        }
        //算法配置方案为算法脚本配置
        if (dataAlgorithmBasicVO.getConfigurationScheme().equals("算法脚本配置")){
            DataAlgorithmScriptConfigVO dataAlgorithmScriptConfigVO = dataAlgorithmScriptAndFormulaVO.getDataAlgorithmScriptConfigVO();
            DataAlgorithmScriptConfigDTO dataAlgorithmScriptConfigDTO = BeanUtils.copyToObject(dataAlgorithmScriptConfigVO, DataAlgorithmScriptConfigDTO.class);
            List<DataAlgorithmParamConfigVO> paramConfigVOList = dataAlgorithmScriptConfigVO.getParamConfigVOList();
            List<DataAlgorithmParamConfigDTO> paramConfigDTO = BeanUtils.copyToList(paramConfigVOList, DataAlgorithmParamConfigDTO.class);
            List<DataAlgorithmParamConfigDTO> paramConfigDTOS = new ArrayList<>();
            //赋值
            paramConfigDTO.forEach(dataAlgorithmParamConfigDTO -> {
                CurrentUserUtils.setUpdateDefaultField(dataAlgorithmParamConfigDTO,currentUserDTO);
                paramConfigDTOS.add(dataAlgorithmParamConfigDTO);
            });

            dataAlgorithmScriptConfigDTO.setParamConfigDTOList(paramConfigDTOS);
            scriptAndFormulaDTO.setDataAlgorithmScriptConfigDTO(dataAlgorithmScriptConfigDTO);
        }
        //更新
        updateAlgorithmScriptOrFormula(scriptAndFormulaDTO);
    }

    /**
     * 删除数据算法
     * @param algorithmId
     * @return
     * @throws ServiceException
     */
    @Override
    public void deleteDataAlgorithm(Long algorithmId) throws ServiceException {
        CurrentUserDTO currentUserDTO = LocalHolder.getCurrentUser();

        //通过算法id获取数据算法DTO对象
        DataAlgorithmDTO dataAlgorithmDTO = getById(algorithmId);
        if (ObjectUtil.isEmpty(dataAlgorithmDTO)){
            throw new ServiceException(DataAlgorithmErrorCodeEnum.PARAM_NOT_FIND.getErrorCode(),DataAlgorithmErrorCodeEnum.PARAM_NOT_FIND.getErrorMessage());
        }
        //修改数据算法状态
        dataAlgorithmDTO.setStatus(GenericStatusEnum.DELETED.getValue());

        CurrentUserUtils.setUpdateDefaultField(dataAlgorithmDTO,currentUserDTO);

        //更新数据算法信息
        update(dataAlgorithmDTO);

        //更新该算法下关联的参数配置信息
        deleteFormulaOrScriptByAlgorithmId(algorithmId);
    }

    /**
     * 禁用数据算法
     * @param algorithmId
     * @return
     * @throws ServiceException
     */
    @Override
    public DataAlgorithmBasicVO disableDataAlgorithm(Long algorithmId) throws ServiceException {
        CurrentUserDTO currentUserDTO = LocalHolder.getCurrentUser();

        //通过算法id获取数据算法DTO对象
        DataAlgorithmDTO dataAlgorithmDTO = getById(algorithmId);
        if (ObjectUtil.isEmpty(dataAlgorithmDTO)){
            throw new ServiceException(DataAlgorithmErrorCodeEnum.PARAM_NOT_FIND.getErrorCode(),DataAlgorithmErrorCodeEnum.PARAM_NOT_FIND.getErrorMessage());
        }
        //修改数据算法状态
        dataAlgorithmDTO.setStatus(GenericStatusEnum.DISABLE.getValue());
        CurrentUserUtils.setUpdateDefaultField(dataAlgorithmDTO,currentUserDTO);
        //更新数据算法信息
       update(dataAlgorithmDTO);

        //返给前端
        return BeanUtils.copyToObject(dataAlgorithmDTO,DataAlgorithmBasicVO.class);
    }

    /**
     * 启用数据算法
     * @param algorithmId
     * @return
     * @throws ServiceException
     */
    @Override
    public DataAlgorithmBasicVO enableDataAlgorithm(Long algorithmId) throws ServiceException {
        CurrentUserDTO currentUserDTO = LocalHolder.getCurrentUser();

        //通过算法id获取数据算法DTO对象
        DataAlgorithmDTO dataAlgorithmDTO =getById(algorithmId);
        if (ObjectUtil.isEmpty(dataAlgorithmDTO)){
            throw new ServiceException(DataAlgorithmErrorCodeEnum.PARAM_NOT_FIND.getErrorCode(),DataAlgorithmErrorCodeEnum.PARAM_NOT_FIND.getErrorMessage());
        }
        //修改数据算法状态
        dataAlgorithmDTO.setStatus(GenericStatusEnum.NORMAL.getValue());
        CurrentUserUtils.setUpdateDefaultField(dataAlgorithmDTO,currentUserDTO);

        //更新数据算法信息
        update(dataAlgorithmDTO);

        //返给前端
        return BeanUtils.copyToObject(dataAlgorithmDTO,DataAlgorithmBasicVO.class);
    }

    /**
     * 删除数据算法
     * @param algorithmId
     * @throws ServiceException
     */
    @Override
    public void deleteParamConfig(Long algorithmId) {
        //通过算法id获取数据算法DTO对象
        DataAlgorithmDTO dataAlgorithmDTO = getById(algorithmId);
        if (ObjectUtil.isEmpty(dataAlgorithmDTO)){
            throw new ServiceException(DataAlgorithmErrorCodeEnum.PARAM_NOT_FIND.getErrorCode(),DataAlgorithmErrorCodeEnum.PARAM_NOT_FIND.getErrorMessage());
        }
        //更新该算法下关联的参数配置信息
        deleteFormulaOrScriptByAlgorithmId(algorithmId);
    }
    public void update(DataAlgorithmDTO dataAlgorithmDTO) throws ServiceException {

        // 将DTO对象的属性复制给DO对象
        DataAlgorithmDO dataAlgorithmDO = BeanUtils.copyToObject(dataAlgorithmDTO, DataAlgorithmDO.class);
        // 修改操作
        dataAlgorithmDAO.updateById(dataAlgorithmDO);
    }

    public PageData<DataAlgorithmDTO> queryPage(DataAlgorithmPageQueryParamDTO dataAlgorithmPageQueryParamDTO) throws ServiceException {
        // 封装查询条件QueryWrapper对象
        QueryWrapper<DataAlgorithmDO> queryWrapper = QueryWrapperUtils.getQueryWrapper(dataAlgorithmPageQueryParamDTO);
        queryWrapper.ne("status", 9);
        queryWrapper.orderByDesc("id");

        // 分页查询统一用户信息信息
        Page<DataAlgorithmDO> page = Page.of(dataAlgorithmPageQueryParamDTO.getPageNo(), dataAlgorithmPageQueryParamDTO.getPageSize());
        PageData<DataAlgorithmDO> pageDataForDO = PageUtils.getPageData(dataAlgorithmDAO.selectPage(page, queryWrapper), dataAlgorithmPageQueryParamDTO);

        return pageDataForDO.transformData(DataAlgorithmDTO.class);
    }
    @Transactional(rollbackFor = Exception.class)
    public DataAlgorithmScriptAndFormulaDTO save(DataAlgorithmScriptAndFormulaDTO algorithmScriptAndFormulaDTO) throws ServiceException {
        DataAlgorithmScriptAndFormulaDTO scriptAndFormulaDTO = new DataAlgorithmScriptAndFormulaDTO();
        //获取各个传参DTO对象
        DataAlgorithmDTO dataAlgorithmBasicDTO = algorithmScriptAndFormulaDTO.getDataAlgorithmDTO();

        //判空
        if (ObjectUtil.isNull(dataAlgorithmBasicDTO)) {
            throw new ServiceException(DataAlgorithmErrorCodeEnum.PARAM_OBJECT_IS_NULL.getErrorCode(), DataAlgorithmErrorCodeEnum.PARAM_OBJECT_IS_NULL.getErrorMessage());
        }

        //对算法名进行判重
        Integer isRepeat = dataAlgorithmDAO.findAlgorithmIsRepeat(dataAlgorithmBasicDTO.getName(), dataAlgorithmBasicDTO.getId());
        Assert.isTrue(isRepeat == 0, DataAlgorithmErrorCodeEnum.NAME_REPEAT);

        String scheme = dataAlgorithmBasicDTO.getConfigurationScheme();
        //算法配置方案为计算公式配置
        if (DataAlgorithmTypeEnum.isFormula(scheme)) {
            DataAlgorithmFormulaConfigDTO dataAlgorithmFormulaConfigDTO = algorithmScriptAndFormulaDTO.getDataAlgorithmFormulaConfigDTO();
            Assert.notNull(dataAlgorithmFormulaConfigDTO, DataAlgorithmErrorCodeEnum.CONFIGURATION_SCHEME_IS_NULL);
            scriptAndFormulaDTO = getAlgorithmFormula(dataAlgorithmBasicDTO, dataAlgorithmFormulaConfigDTO);
        }

        //算法配置方案为算法脚本配置
        if (DataAlgorithmTypeEnum.isScript(scheme)) {
            DataAlgorithmScriptConfigDTO dataAlgorithmScriptConfigDTO = algorithmScriptAndFormulaDTO.getDataAlgorithmScriptConfigDTO();
            Assert.notNull(dataAlgorithmScriptConfigDTO, DataAlgorithmErrorCodeEnum.CONFIGURATION_SCHEME_IS_NULL);
            scriptAndFormulaDTO = getAlgorithmScript(dataAlgorithmBasicDTO, dataAlgorithmScriptConfigDTO);
        }
        return scriptAndFormulaDTO;
    }
    public DataAlgorithmScriptAndFormulaDTO getFormulaOrScriptById(Long algorithmId) {
        DataAlgorithmScriptAndFormulaDTO scriptAndFormulaDTO = new DataAlgorithmScriptAndFormulaDTO();
        //根据算法id查询算法基本信息
        DataAlgorithmDO dataAlgorithmDO = dataAlgorithmDAO.selectById(algorithmId);

        if (ObjectUtil.isNull(dataAlgorithmDO)) {
            throw new ServiceException(DataAlgorithmErrorCodeEnum.PARAM_NOT_FIND.getErrorCode(), DataAlgorithmErrorCodeEnum.PARAM_NOT_FIND.getErrorMessage());
        }
        //算法基本信息DO对象转为DTO对象
        DataAlgorithmDTO dataAlgorithmDTO = BeanUtils.copyToObject(dataAlgorithmDO, DataAlgorithmDTO.class);
        scriptAndFormulaDTO.setDataAlgorithmDTO(dataAlgorithmDTO);

        //当算法配置方案为计算公式配置
        if (dataAlgorithmDO.getConfigurationScheme().equals("计算公式配置")) {
            List<DataAlgorithmParamConfigDTO> paramConfigDTOS = new ArrayList<>();
            DataAlgorithmFormulaConfigDTO formulaConfigDTO = new DataAlgorithmFormulaConfigDTO();
            //获取计算参数配置信息
            List<DataAlgorithmParamConfigDO> paramConfigDOList = algorithmParamConfigDAO.findParamConfigByAlgorithmId(algorithmId);
            if (CollectionUtil.isEmpty(paramConfigDOList)) {
                paramConfigDTOS = new ArrayList<>();
            } else {
                paramConfigDTOS = BeanUtils.copyToList(paramConfigDOList, DataAlgorithmParamConfigDTO.class);
            }

            //获取计算公式
            List<DataAlgorithmFormulaConfigDO> formulaConfigDOList = algorithmFormulaConfigDAO.findFormulaConfigByAlgorithmId(algorithmId);
            if (CollectionUtil.isEmpty(formulaConfigDOList)) {
                formulaConfigDTO = new DataAlgorithmFormulaConfigDTO();
            } else {
                DataAlgorithmFormulaConfigDO formulaConfig = formulaConfigDOList.get(0);
                formulaConfigDTO = BeanUtils.copyToObject(formulaConfig, DataAlgorithmFormulaConfigDTO.class);
            }
            //赋值
            formulaConfigDTO.setAlgorithmId(algorithmId);
            formulaConfigDTO.setParamConfigDTOList(paramConfigDTOS);

            scriptAndFormulaDTO.setDataAlgorithmFormulaConfigDTO(formulaConfigDTO);
        }
        //当算法配置方案为算法脚本配置
        if (dataAlgorithmDO.getConfigurationScheme().equals("算法脚本配置")) {
            List<DataAlgorithmParamConfigDTO> paramConfigDOS = new ArrayList<>();
            DataAlgorithmScriptConfigDTO scriptConfigDTO = new DataAlgorithmScriptConfigDTO();
            //获取计算参数配置信息
            List<DataAlgorithmParamConfigDO> paramConfigDOList = algorithmParamConfigDAO.findParamConfigInfoById(algorithmId);
            if (CollectionUtil.isEmpty(paramConfigDOList)) {
                paramConfigDOS = new ArrayList<>();
            } else {
                paramConfigDOS = BeanUtils.copyToList(paramConfigDOList, DataAlgorithmParamConfigDTO.class);
            }

            //获取计算公式
            List<DataAlgorithmScriptConfigDO> scriptList = algorithmScriptConfigDAO.findScriptConfigInfoByAlgorithmId(algorithmId);
            if (CollectionUtil.isEmpty(scriptList)) {
                scriptConfigDTO = new DataAlgorithmScriptConfigDTO();
            } else {
                DataAlgorithmScriptConfigDO scriptConfigDO = algorithmScriptConfigDAO.findScriptConfigInfoByAlgorithmId(algorithmId).get(0);
                scriptConfigDTO = BeanUtils.copyToObject(scriptConfigDO, DataAlgorithmScriptConfigDTO.class);
            }
            //赋值
            scriptConfigDTO.setAlgorithmId(algorithmId);
            scriptConfigDTO.setParamConfigDTOList(paramConfigDOS);

            scriptAndFormulaDTO.setDataAlgorithmScriptConfigDTO(scriptConfigDTO);
        }
        return scriptAndFormulaDTO;
    }

    public void updateAlgorithmScriptOrFormula(DataAlgorithmScriptAndFormulaDTO dataAlgorithmScriptAndFormulaDTO) throws ServiceException {

        DataAlgorithmDTO dataAlgorithmDTO = dataAlgorithmScriptAndFormulaDTO.getDataAlgorithmDTO();

        //当算法配置方案为计算公式配置
        if (dataAlgorithmDTO.getConfigurationScheme().equals("计算公式配置")) {
            DataAlgorithmFormulaConfigDTO dataAlgorithmFormulaConfigDTO = dataAlgorithmScriptAndFormulaDTO.getDataAlgorithmFormulaConfigDTO();
            updateAlgorithmFormula(dataAlgorithmDTO, dataAlgorithmFormulaConfigDTO);
        }

        //当算法配置方案为算法脚本配置
        if (dataAlgorithmDTO.getConfigurationScheme().equals("算法脚本配置")) {
            DataAlgorithmScriptConfigDTO dataAlgorithmScriptConfigDTO = dataAlgorithmScriptAndFormulaDTO.getDataAlgorithmScriptConfigDTO();
            updateAlgorithmScript(dataAlgorithmDTO, dataAlgorithmScriptConfigDTO);
        }
    }

    public DataAlgorithmDTO getById(Long algorithmId) {
        DataAlgorithmDO dataAlgorithmDO = dataAlgorithmDAO.selectById(algorithmId);
        return BeanUtils.copyToObject(dataAlgorithmDO, DataAlgorithmDTO.class);
    }
    public void deleteFormulaOrScriptByAlgorithmId(Long algorithmId) {
        DataAlgorithmDO dataAlgorithmDO = dataAlgorithmDAO.selectById(algorithmId);
        //算法方案为计算公式配置
        if (dataAlgorithmDO.getConfigurationScheme().equals("计算公式配置")) {
            List<DataAlgorithmFormulaConfigDO> formulaConfigDOList = algorithmFormulaConfigDAO.findFormulaConfigByAlgorithmId(algorithmId);

            if (CollectionUtil.isNotEmpty(formulaConfigDOList)) {
                //删除参数配置信息
                formulaConfigDOList.forEach(dataAlgorithmFormulaConfigDO -> {
                    algorithmParamConfigDAO.deleteById(dataAlgorithmFormulaConfigDO.getAlgorithmParamId());
                });

                //删除计算公式配置信息
                algorithmFormulaConfigDAO.deleteBatchIds(formulaConfigDOList);
            }
        }
        //算法方案为算法脚本配置
        if (dataAlgorithmDO.getConfigurationScheme().equals("算法脚本配置")) {
            List<DataAlgorithmScriptConfigDO> scriptConfigInfos = algorithmScriptConfigDAO.findScriptConfigInfoByAlgorithmId(algorithmId);
            if (CollectionUtil.isNotEmpty(scriptConfigInfos)) {
                //删除参数配置信息
                scriptConfigInfos.forEach(dataAlgorithmScriptConfigDO -> {
                    algorithmParamConfigDAO.deleteById(dataAlgorithmScriptConfigDO.getParamConfigurationId());
                });

                //删除算法脚本配置信息
                algorithmScriptConfigDAO.deleteBatchIds(scriptConfigInfos);
            }
        }
    }
    private void updateAlgorithmFormula(DataAlgorithmDTO dataAlgorithmDTO, DataAlgorithmFormulaConfigDTO formulaConfigDTO) {
        // 将数据算法基本信息DTO对象的属性复制给DO对象
        DataAlgorithmDO dataAlgorithmDO = BeanUtils.copyToObject(dataAlgorithmDTO, DataAlgorithmDO.class);
        // 修改数据算法基本信息
        dataAlgorithmDAO.updateById(dataAlgorithmDO);

        List<DataAlgorithmScriptConfigDO> scriptConfigInfo = algorithmScriptConfigDAO.findScriptConfigInfoByAlgorithmId(dataAlgorithmDTO.getId());
        List<DataAlgorithmParamConfigDTO> paramConfigDTOList = formulaConfigDTO.getParamConfigDTOList();
        //若根据算法基本信息id查不到算法脚本配置，说明原来是计算公式配置，只是修改计算公式参数配置
        //否则，先删除关联关系再重新插入
        if (CollectionUtil.isEmpty(scriptConfigInfo)) {

            paramConfigDTOList.stream().forEach(dataAlgorithmParamConfigDTO -> {
                DataAlgorithmFormulaConfigDO formulaConfigDO = algorithmFormulaConfigDAO.findFormulaConfigByAlgorithmParamId(dataAlgorithmParamConfigDTO.getId());
                if (ObjectUtil.isNull(formulaConfigDO)) {
                    DataAlgorithmFormulaConfigDO dataAlgorithmFormulaConfigDO = new DataAlgorithmFormulaConfigDO();
                    dataAlgorithmFormulaConfigDO.setFormula(formulaConfigDTO.getFormula());
                    dataAlgorithmFormulaConfigDO.setAlgorithmId(dataAlgorithmDO.getId());

                    //操作算法参数配置表
                    DataAlgorithmParamConfigDO algorithmParamConfigDO = BeanUtils.copyToObject(dataAlgorithmParamConfigDTO, DataAlgorithmParamConfigDO.class);
                    algorithmParamConfigDAO.insert(algorithmParamConfigDO);
                    dataAlgorithmFormulaConfigDO.setAlgorithmParamId(algorithmParamConfigDO.getId());

                    //操作计算公式配置表
                    algorithmFormulaConfigDAO.insert(dataAlgorithmFormulaConfigDO);
                } else {
                    formulaConfigDO.setFormula(formulaConfigDTO.getFormula());
                    algorithmParamConfigDAO.deleteById(dataAlgorithmParamConfigDTO.getId());
                    DataAlgorithmParamConfigDO algorithmParamConfigDO = BeanUtils.copyToObject(dataAlgorithmParamConfigDTO, DataAlgorithmParamConfigDO.class);
                    algorithmParamConfigDO.setId(null);
                    algorithmParamConfigDAO.insert(algorithmParamConfigDO);
                    // 将id设置给算法基本信息DTO对象
                    dataAlgorithmParamConfigDTO.setId(algorithmParamConfigDO.getId());
                    formulaConfigDO.setAlgorithmParamId(dataAlgorithmParamConfigDTO.getId());
                    // 修改计算公式配置信息
                    algorithmFormulaConfigDAO.updateById(formulaConfigDO);
                }
            });
        } else {
            //删除原来算法脚本的参数配置
            List<Long> collect = scriptConfigInfo.stream().map(DataAlgorithmScriptConfigDO::getParamConfigurationId).collect(Collectors.toList());
            algorithmParamConfigDAO.deleteBatchIds(collect);
            //删除原来算法脚本配置
            algorithmScriptConfigDAO.deleteBatchIds(scriptConfigInfo);

            //将修改数据新增到对应的表里
            paramConfigDTOList.stream().forEach(dataAlgorithmParamConfigDTO -> {
                //给新建对象赋值
                DataAlgorithmFormulaConfigDO dataAlgorithmFormulaConfigDO = new DataAlgorithmFormulaConfigDO();
                dataAlgorithmFormulaConfigDO.setFormula(formulaConfigDTO.getFormula());
                dataAlgorithmFormulaConfigDO.setAlgorithmId(dataAlgorithmDO.getId());

                //操作算法参数配置表
                DataAlgorithmParamConfigDO algorithmParamConfigDO = BeanUtils.copyToObject(dataAlgorithmParamConfigDTO, DataAlgorithmParamConfigDO.class);

                algorithmParamConfigDAO.insert(algorithmParamConfigDO);
                dataAlgorithmFormulaConfigDO.setAlgorithmParamId(algorithmParamConfigDO.getId());

                //操作计算公式配置表
                algorithmFormulaConfigDAO.insert(dataAlgorithmFormulaConfigDO);
            });
        }
    }
    private void updateAlgorithmScript(DataAlgorithmDTO dataAlgorithmDTO, DataAlgorithmScriptConfigDTO scriptConfigDTO) {
        // 将数据算法基本信息DTO对象的属性复制给DO对象
        DataAlgorithmDO dataAlgorithmDO = BeanUtils.copyToObject(dataAlgorithmDTO, DataAlgorithmDO.class);
        // 修改数据算法基本信息
        dataAlgorithmDAO.updateById(dataAlgorithmDO);
        List<DataAlgorithmFormulaConfigDO> formulaConfigInfo = algorithmFormulaConfigDAO.findFormulaConfigByAlgorithmId(dataAlgorithmDTO.getId());
        List<DataAlgorithmParamConfigDTO> paramConfigDTOList = scriptConfigDTO.getParamConfigDTOList();
        //若根据算法基本信息id查不到计算公式配置，说明原来是算法脚本配置，只是修改算法脚本配置
        //否则，先删除关联关系再重新插入
        if (CollectionUtil.isEmpty(formulaConfigInfo)) {
            paramConfigDTOList.stream().forEach(dataAlgorithmParamConfigDTO -> {
                DataAlgorithmScriptConfigDO scriptConfigDO = algorithmScriptConfigDAO.findScriptConfigByParamConfigId(dataAlgorithmParamConfigDTO.getId());
                if (ObjectUtil.isNull(scriptConfigDO)) {
                    DataAlgorithmScriptConfigDO dataAlgorithmScriptConfigDO = new DataAlgorithmScriptConfigDO();
                    dataAlgorithmScriptConfigDO.setScriptPath(scriptConfigDTO.getScriptPath());
                    dataAlgorithmScriptConfigDO.setAlgorithmId(dataAlgorithmDO.getId());
                    dataAlgorithmScriptConfigDO.setRequestType(scriptConfigDTO.getRequestType());

                    //操作算法参数配置表
                    DataAlgorithmParamConfigDO algorithmParamConfigDO = BeanUtils.copyToObject(dataAlgorithmParamConfigDTO, DataAlgorithmParamConfigDO.class);

                    algorithmParamConfigDAO.insert(algorithmParamConfigDO);
                    dataAlgorithmScriptConfigDO.setParamConfigurationId(algorithmParamConfigDO.getId());
                    // 将id设置给算法参数配置DTO对象
                    dataAlgorithmParamConfigDTO.setId(algorithmParamConfigDO.getId());

                    //操作计算公式配置表
                    algorithmScriptConfigDAO.insert(dataAlgorithmScriptConfigDO);
                } else {
                    scriptConfigDO.setScriptPath(scriptConfigDTO.getScriptPath());
                    scriptConfigDO.setRequestType(scriptConfigDTO.getRequestType());
                    boolean exists = algorithmParamConfigDAO.exists(Wrappers.<DataAlgorithmParamConfigDO>lambdaQuery()
                            .eq(DataAlgorithmParamConfigDO::getId, dataAlgorithmParamConfigDTO.getId()));
//                    Integer isIsRepeat = algorithmParamConfigDAO.findParamConfigIsIsRepeat(dataAlgorithmParamConfigDTO.getId());
                    //判断是否存在，存在则更新，不存在则插入
                    if (exists) {
                        DataAlgorithmParamConfigDO algorithmParamConfigDO = BeanUtils.copyToObject(dataAlgorithmParamConfigDTO, DataAlgorithmParamConfigDO.class);
                        // 修改数据算法基本信息
                        algorithmParamConfigDAO.updateById(algorithmParamConfigDO);
                    } else {
                        DataAlgorithmParamConfigDO algorithmParamConfigDO = new DataAlgorithmParamConfigDO();
                        DataAlgorithmParamConfigDO algorithmParamConfig = BeanUtils.copyToObject(dataAlgorithmParamConfigDTO, DataAlgorithmParamConfigDO.class);
                        BeanUtils.copyObject(algorithmParamConfig, algorithmParamConfigDO);

                        algorithmParamConfigDAO.insert(algorithmParamConfigDO);
                        // 将id设置给算法基本信息DTO对象
                        dataAlgorithmParamConfigDTO.setId(algorithmParamConfigDO.getId());
                        scriptConfigDO.setParamConfigurationId(dataAlgorithmParamConfigDTO.getId());
                    }
                    // 修改计算公式配置信息
                    algorithmScriptConfigDAO.updateById(scriptConfigDO);
                }
            });

        } else {
            //先删除参数配置信息，在删除计算公式配置
            formulaConfigInfo.forEach(dataAlgorithmFormulaConfigDO -> {
                algorithmParamConfigDAO.deleteById(dataAlgorithmFormulaConfigDO.getAlgorithmParamId());
            });
            //删除原来计算公式配置
            algorithmFormulaConfigDAO.deleteBatchIds(formulaConfigInfo);
            paramConfigDTOList.stream().forEach(dataAlgorithmParamConfigDTO -> {

                DataAlgorithmScriptConfigDO dataAlgorithmScriptConfigDO = new DataAlgorithmScriptConfigDO();
                dataAlgorithmScriptConfigDO.setScriptPath(scriptConfigDTO.getScriptPath());
                dataAlgorithmScriptConfigDO.setRequestType(scriptConfigDTO.getRequestType());
                dataAlgorithmScriptConfigDO.setAlgorithmId(dataAlgorithmDO.getId());

                //操作算法参数配置表
                DataAlgorithmParamConfigDO algorithmParamConfigDO = BeanUtils.copyToObject(dataAlgorithmParamConfigDTO, DataAlgorithmParamConfigDO.class);

                algorithmParamConfigDAO.insert(algorithmParamConfigDO);
                dataAlgorithmScriptConfigDO.setParamConfigurationId(algorithmParamConfigDO.getId());

                //操作计算公式配置表
                algorithmScriptConfigDAO.insert(dataAlgorithmScriptConfigDO);
            });
        }
    }

    private DataAlgorithmScriptAndFormulaDTO getAlgorithmScript(DataAlgorithmDTO dataAlgorithmBasicDTO, DataAlgorithmScriptConfigDTO scriptConfigDTO) {
        DataAlgorithmScriptAndFormulaDTO dataAlgorithmScriptAndFormulaDTO = new DataAlgorithmScriptAndFormulaDTO();
        //操作数据算法基本信息表
        DataAlgorithmDO dataAlgorithmDO = BeanUtils.copyToObject(dataAlgorithmBasicDTO, DataAlgorithmDO.class);
        dataAlgorithmDAO.insert(dataAlgorithmDO);
        // 将id设置给算法基本信息DTO对象
        dataAlgorithmBasicDTO.setId(dataAlgorithmDO.getId());

        List<DataAlgorithmParamConfigDTO> paramConfigDTOList = scriptConfigDTO.getParamConfigDTOList();
        List<DataAlgorithmParamConfigDTO> list = new ArrayList<>();
        paramConfigDTOList.stream().forEach(dataAlgorithmParamConfigDTO -> {

            DataAlgorithmScriptConfigDO dataAlgorithmScriptConfigDO = new DataAlgorithmScriptConfigDO();
            dataAlgorithmScriptConfigDO.setScriptPath(scriptConfigDTO.getScriptPath());
            dataAlgorithmScriptConfigDO.setAlgorithmId(dataAlgorithmDO.getId());
            dataAlgorithmScriptConfigDO.setRequestType(scriptConfigDTO.getRequestType());

            //操作算法参数配置表
            DataAlgorithmParamConfigDO algorithmParamConfigDO = BeanUtils.copyToObject(dataAlgorithmParamConfigDTO, DataAlgorithmParamConfigDO.class);

            Integer isIsRepeat = algorithmParamConfigDAO.findParamConfigIsIsRepeat(dataAlgorithmParamConfigDTO.getId());

            if (isIsRepeat > 0) {
                throw new ServiceException(DataAlgorithmErrorCodeEnum.MARK__REPEAT.getErrorCode(), DataAlgorithmErrorCodeEnum.MARK__REPEAT.getErrorMessage());
            }
            algorithmParamConfigDAO.insert(algorithmParamConfigDO);
            dataAlgorithmScriptConfigDO.setParamConfigurationId(algorithmParamConfigDO.getId());
            // 将id设置给算法参数配置DTO对象
            dataAlgorithmParamConfigDTO.setId(algorithmParamConfigDO.getId());

            //操作计算公式配置表
            algorithmScriptConfigDAO.insert(dataAlgorithmScriptConfigDO);
            scriptConfigDTO.setId(dataAlgorithmScriptConfigDO.getId());
            scriptConfigDTO.setAlgorithmId(dataAlgorithmDO.getId());

            list.add(dataAlgorithmParamConfigDTO);

        });
        scriptConfigDTO.setParamConfigDTOList(list);
        //赋值
        dataAlgorithmScriptAndFormulaDTO.setDataAlgorithmDTO(dataAlgorithmBasicDTO);
        dataAlgorithmScriptAndFormulaDTO.setDataAlgorithmScriptConfigDTO(scriptConfigDTO);
        return dataAlgorithmScriptAndFormulaDTO;
    }

    private DataAlgorithmScriptAndFormulaDTO getAlgorithmFormula(DataAlgorithmDTO dataAlgorithmBasicDTO, DataAlgorithmFormulaConfigDTO formulaConfigDTO) {
        DataAlgorithmScriptAndFormulaDTO dataAlgorithmScriptAndFormulaDTO = new DataAlgorithmScriptAndFormulaDTO();
        //操作数据算法基本信息表
        DataAlgorithmDO dataAlgorithmDO = BeanUtils.copyToObject(dataAlgorithmBasicDTO, DataAlgorithmDO.class);
        dataAlgorithmDAO.insert(dataAlgorithmDO);
        // 将id设置给算法基本信息DTO对象
        dataAlgorithmBasicDTO.setId(dataAlgorithmDO.getId());

        List<DataAlgorithmParamConfigDTO> paramConfigDTOList = formulaConfigDTO.getParamConfigDTOList();
        List<DataAlgorithmParamConfigDTO> list = new ArrayList<>();
        paramConfigDTOList.stream().forEach(dataAlgorithmParamConfigDTO -> {

            DataAlgorithmFormulaConfigDO dataAlgorithmFormulaConfigDO = new DataAlgorithmFormulaConfigDO();
            dataAlgorithmFormulaConfigDO.setFormula(formulaConfigDTO.getFormula());
            dataAlgorithmFormulaConfigDO.setAlgorithmId(dataAlgorithmDO.getId());

            //操作算法参数配置表
            DataAlgorithmParamConfigDO algorithmParamConfigDO = BeanUtils.copyToObject(dataAlgorithmParamConfigDTO, DataAlgorithmParamConfigDO.class);

            Integer isIsRepeat = algorithmParamConfigDAO.findParamConfigIsIsRepeat(dataAlgorithmParamConfigDTO.getId());

            if (isIsRepeat > 0) {
                throw new ServiceException(DataAlgorithmErrorCodeEnum.MARK__REPEAT.getErrorCode(), DataAlgorithmErrorCodeEnum.MARK__REPEAT.getErrorMessage());
            }
            algorithmParamConfigDAO.insert(algorithmParamConfigDO);
            dataAlgorithmFormulaConfigDO.setAlgorithmParamId(algorithmParamConfigDO.getId());
            // 将id设置给算法参数配置DTO对象
            dataAlgorithmParamConfigDTO.setId(algorithmParamConfigDO.getId());

            //操作计算公式配置表
            algorithmFormulaConfigDAO.insert(dataAlgorithmFormulaConfigDO);
            formulaConfigDTO.setId(dataAlgorithmFormulaConfigDO.getId());
            formulaConfigDTO.setAlgorithmId(dataAlgorithmDO.getId());

            list.add(dataAlgorithmParamConfigDTO);
        });
        formulaConfigDTO.setParamConfigDTOList(list);
        //赋值
        dataAlgorithmScriptAndFormulaDTO.setDataAlgorithmDTO(dataAlgorithmBasicDTO);
        dataAlgorithmScriptAndFormulaDTO.setDataAlgorithmFormulaConfigDTO(formulaConfigDTO);
        return dataAlgorithmScriptAndFormulaDTO;
    }


}
